//
//  CinemaDViewController.m
//  UI12豆瓣大项目
//
//  Created by 李奇 on 15/10/31.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//
#define WIDTH  [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height

#import "CinemaDViewController.h"
#import "CinemaDetailView.h"
#import "AppTools.h"
#import "UIImageView+WebCache.h"
#import "MBProgressHUD.h"
#import "LoginViewController.h"
@interface CinemaDViewController ()
@property (nonatomic,retain) MBProgressHUD *hub;
@end

@implementation CinemaDViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CinemaDetailView *cinemaDetailV = [[CinemaDetailView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.view addSubview:cinemaDetailV];
    [cinemaDetailV release];
    
    UIScrollView *scrollV = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    scrollV.contentSize = CGSizeMake(WIDTH, HEIGHT + 250);
    [scrollV addSubview:cinemaDetailV];
    [self.view addSubview:scrollV];
    //请求数据
    NSString *detailURL = [NSString stringWithFormat:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/searchcinema.php?cinemaId=%@",self.movieId];
    NSLog(@"0999999%@",self.movieId);
    [AppTools getDataWithkey:detailURL block:^(id result) {
        NSMutableDictionary *bigdic = result;
        NSLog(@"result=%@",result);
        NSString *reason = [bigdic objectForKey:@"reason"];
        if ([reason isEqualToString:@"success"]) {
            NSMutableDictionary *dic1 = [bigdic objectForKey:@"result"];
            NSMutableDictionary *dic = [dic1 objectForKey:@"cinema_info"];
            self.activity = [[Activity alloc] init];
            [self.activity setValuesForKeysWithDictionary: dic];
            NSLog(@"========================%@", self.activity);
            //直接传对象
            
#pragma mark --没有这个不写啦?!
//            self.navigationItem.title = self.activity.cinemaName;
            NSLog(@"0000%@", self.activity.city);
            //重写方法
            cinemaDetailV.activity = self.activity;
        }else{
            NSLog(@"请求失败");
        }
        
    }];
    
    
    //左右Bar
    UIImage *leftImage = [UIImage imageNamed:@"btn_nav_back@2x"];
    //取消渲染
    leftImage = [leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:leftImage style:UIBarButtonItemStylePlain target:self action:@selector(leftBarAction:)];
    
    UIImage *rightImage = [UIImage imageNamed:@"btn_nav_share@2x"];
    //取消渲染
    rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:rightImage style:UIBarButtonItemStylePlain target:self action:@selector(rightBarAction:)];
    
    
    
    [scrollV release];
    // Do any additional setup after loading the view.
}

//左侧按钮
-(void)leftBarAction:(UIButton *)barbutton{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

//右侧按钮
-(void)rightBarAction:(UIBarButtonItem *)barbutton{
    //    NSLog(@"djokp");
    LoginViewController *loginViewVC = [[LoginViewController alloc] init];
    //模态要重建UINavigation..
    UINavigationController *loginViewnaC = [[UINavigationController alloc] initWithRootViewController:loginViewVC];
    [self presentViewController:loginViewnaC animated:YES completion:^{
        
        
    }];
    [loginViewnaC release];
    [loginViewVC release];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
